package lesson02;

public class Demo_202 {
    public static void main(String[] args) {
        Thread thread2=new Thread(()-> {
            while (true) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName()+66666);
            }
        },"我是一个线程");
        //thread常见属性
        System.out.println("ID:" + thread2.getId());
        System.out.println("name:" + thread2.getName());
        System.out.println("状态:" + thread2.getState());
        System.out.println("优先级:" + thread2.getPriority());
        System.out.println("是否后台进程:" + thread2.isDaemon());
        System.out.println("是否存活:" + thread2.isAlive());
        System.out.println("是否中断:" + thread2.isInterrupted());

        //设置为后台线程
        thread2.setDaemon(true);
        thread2.start();
        System.out.println("是否存活:" + thread2.isAlive());
    }
}
